//
//  AttributeCell.swift
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/2/1.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

import Foundation

class AttributesCell: UICollectionViewCell {
    let imageView: UIImageView = {
        let imageView = UIImageView()

        imageView.contentMode = .center
        return imageView
    }()

    let bgImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFill
        return imageView
    }()

    var attributeSelected = false {
        didSet {
            bgImageView.image = attributeSelected ? #imageLiteral(resourceName: "colorXuan") : nil
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)

        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        setup()
    }

    private func setup() {
        contentView.addSubview(bgImageView)
        contentView.addSubview(imageView)

        imageView.mas_makeConstraints { (make) in
            make?.edges.equalTo()(contentView)?.insets()(7.insets)
        }
        bgImageView.mas_makeConstraints { (make) in
            make?.edges.equalTo()(contentView)?.insets()(1.insets)
        }
    }
}
